
// from http://www.java-forums.org/awt-swing/6574-add-image-jframe.html
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class ImagePanel extends JPanel {
	private Image m_image;

	public ImagePanel(Image img){
		m_image= img;
		Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);
		setLayout(null);
	}
	public ImagePanel(String path) {
		this(new ImageIcon(path).getImage());
	}

	public void paintComponent(Graphics g) {
		g.drawImage(m_image, 0, 0, null);
		//super.paintComponent(g);
		// Draw image centered.
//		int x = (getWidth() - image.getWidth()) / 2;
//		int y = (getHeight() - image.getHeight()) / 2;
//		g.drawImage(image, x, y, this);
	}
}
